home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / shadobox.arc / SHADOBOX.DOC < prev    next >
Text File  |  1988-11-19  |  37KB  |  792 lines

  1. SHADOBOX.DOC ver 0.0  11/21/87
  2.  
  3.                                  SHADOW BOXES
  4.                       the Donohue&Co. Windowing package
  5.                         for TurboC and some other compilers*
  6.                                  Documentation
  7.  
  8. Copyright (c) 1987 John G. Donohue
  9.                    Donohue&Co. Computer Services
  10.                    PO Box 255
  11.                    Hannibal, NY  13074
  12.                    (315) 564-6213
  13.  
  14.       This product is not public domain.  It is the exclusive property
  15.       of John G. Donohue, and may not be used without his consent.
  16.       No translation of the product to any other environment may be made
  17.       in any form without written permission of Donohue&Co.
  18.       This document and the object files used to form programs with
  19.       windowing form a shareware product: You are encouraged to copy it
  20.       and share it with others freely, for disk copying fees up to $3,
  21.       but not for profit.  Dealership arrangements of the Source Code
  22.       product are available.
  23.  
  24.       Donohue&Co. makes no warranties, expressed nor implied, as to the
  25.       merchantability or fitness of any part of this product for any
  26.       particular purpose.  Further, Donohue&Co. shall not be responsible 
  27.       for damages of any kind, including consequential damages, resulting
  28.       from use of this product.
  29.  
  30.               --------------------- o  o  o ---------------------
  31.  
  32. WHAT IS THIS PACKAGE?
  33.  
  34. This package contains the necessary data structures and functions to allow
  35. a C programmer to construct efficent, visually appealing programs.
  36.  
  37. Typically, a windowing library sells for $100 to $200.  But other packages
  38. don't give you the truly EXTRAORDINARY control over 
  39.  
  40.         borders (you can mix ANY combination of styles on ANY of the
  41.         four sides, including no border on one side),
  42.  
  43.         shadows (REAL SHADOWS that "darken" the text in shadow!),
  44.         [That's why we call it "Shadow Boxes"]
  45.  
  46.                                       and
  47.  
  48.         retaining contents (optionally) of windows even when they are closed.
  49.  
  50. We're distributing this version in shareware for two reasons:
  51.  
  52.         So you can run WDEMO and be convinced this is the nicest package
  53.         you've seen, without ever investing a cent.  (And if you like it,
  54.         and you have a TurboC compiler, you can use it freely forever.)
  55.  
  56.         If you want the Source Code, or a version for another popular compiler,
  57.         you can get BOTH for less than half -- less than a fourth! --
  58.         of what other windowing libraries would cost WITHOUT source code --
  59.  
  60.                          Just $45 for FULL WINDOWS SOURCE CODE!
  61.  
  62.         PULL-DOWN MENUS available!
  63.  
  64.         If you want PULL-DOWN (and other) MENUS, you can have those too --
  65.         with an unbelievable array of menu features:
  66.  
  67.              Horizontal or Vertical or "Wordy," with choices interspersed
  68.              Lotus-style bar menus, (if you want), or use special keys
  69.              Help messages for each choice on the menu
  70.              "Invisible" menu choices possible
  71.              Hang menus off previous choices
  72.              Key menu colors in a hierarchy
  73.              All window attributes apply to menus, even Shadows, if you like.
  74.  
  75.              and FULL MENU SOURCE CODE!
  76.  
  77.         If you order the Menu Package at the same time as the
  78.         Window Source Code, you get the Menus Package for just $15!
  79.         Ordered later, it's $25.
  80.  
  81.         Application consulting is available by phone or in person
  82.         at normal consulting rates.
  83.  
  84. When you purchase any of the above, you will receive the latest version,
  85. with newer features and expanded documentation, as well as availability
  86. of later versions at very modest charges.
  87. At any time, the Source Code version may have additional features
  88. beyond those of the shareware version.
  89.  
  90.   This version contains precompiled modules (*.OBJ), a demo file in both
  91.   source and executable form (WDEMO.C and WDEMO.EXE), and instructions.
  92.   The OBJ files are suitable for use with Turbo C or Microsoft C version 3
  93.   or later, but probably not with other compilers.
  94.   (Different compilers use the 8088's registers differently.)
  95.   If you wish to use the modules with another compiler,
  96.   you must purchase the source code version and compile it yourself.
  97.   The price is modest, and you will have an excellent example of 
  98.   highly portable C source code to study.
  99.  
  100.  
  101.               --------------------- o  o  o ---------------------
  102.  
  103.                            How to use "SHADOW BOXES",
  104.                        the Donohue&Co. Windowing package
  105.  
  106. FEATURES
  107.  
  108.   You may create any number of overlapping windows, and "lift them off"
  109.   each other to display what they "covered".  There is always a "bottom
  110.   window", which is the screen that appeared when the program was invoked.
  111.   There is no automatic clearing of the screen when execution begins, so
  112.   you may utilize a form which is independent of the windowing system in
  113.   the "standard screen" (bottom window).
  114.  
  115.   Color may be used functionally or decoratively, and you have a variety 
  116.   of specific control over each window's borders, shadows, and location, 
  117.   and the edge of the screen.
  118.  
  119.   Your writing is not restricted to the "top" window.
  120.   Although you may not write on a the part of a window which is "covered" 
  121.   by another window, you MAY write on the visible (uncovered) portion of ANY
  122.   window.
  123.  
  124.   You may scroll windows, either by command or by outputting a '\n' character.
  125.  
  126.   You may mix borders in one window, individually controlling each of the
  127.   four sides, if you wish:
  128.     (bar across the top, single line on left side, 
  129.      double line on right side, NO BORDER on bottom)
  130.   -- and the corners figure themselves out!
  131.   On a long, top-to-bottom-of-the-screen menu, you might choose to have a
  132.   left and right border, but no top or bottom, so you can scroll it up and
  133.   down off the page.
  134.  
  135.   The border may be different background and foreground colors from the
  136.   main text area.
  137.  
  138.   Cursor locations begin at (0,0), the upper left hand corner of the
  139.   WRITEABLE PORTION of the window.  However, you MAY write on the borders,
  140.   or even outside the window, if you insist.
  141.  
  142.   You cannot write to a defined-but-undisplayed window in this version.
  143.  
  144.   A window's shadow, if you select one, is always on the left and bottom
  145.   of the window.  It dims characters it covers, and makes their background
  146.   black.
  147.  
  148.   A window may be displayed in only one place AT A TIME on screen, but
  149.   may be "closed" and "reopened" in a different location.  It RETAINS ITS
  150.   PREVIOUS CONTENTS, unless it was defined with the CLEAR_ON_OPEN bit set.
  151.  
  152.   You may constantly change the colors of characters, by "setting" a new
  153.   foreground or background color, bright, blinking, or any combination.
  154.   Once a setting is made, it applies to all subsequent characters displayed
  155.   until changed again.  When the window scrolls, the new line is filled with
  156.   the INITIAL DEFAULT BACKGROUND COLOR, not the current color.  If the
  157.   window is "closed" and "reopened", it remembers THAT WINDOW'S last
  158.   color/bright/blinking setting (its "attribute"), and its last 
  159.   cursor position.
  160.  
  161.   There is a foreground/background color combination called TRANSPARENT,
  162.   designed for a special use.
  163.   Normally, you set a color attribute, then you display text, and the text
  164.   appears in the color combination chosen.  
  165.   However, some people prefer to display an entire "mask" or "form" with
  166.   boxes of various colors already there.  In this case, instead of setting
  167.   the appropriate attribute before displaying characters in each box, you
  168.   may simply set the attribute TRANSPARENT, and subsequently displayed
  169.   character will appear in the color combination that the location ALREADY HAS.
  170.   Therefore, if you overwrite characters that were RED foreground and
  171.   BLUE background, the characters you write will appear in THAT combination
  172.   -- EVEN IF YOU CROSS COLOR BOUNDARIES WITHIN THE TEXT YOU WRITE!
  173.   This is useful for writing a single string, but having it "land" in
  174.   different color "boxes".  They will always be the right color.
  175.  
  176.   If the window is full-screen in size (or even if it is not), you may
  177.   set the screen edge (outside the largest rectangle) to the
  178.   border background color.
  179.  
  180.  
  181. PROCEDURES
  182.  
  183.   You must initialize the windowing system before using any other
  184.   windowing function.  No visible effect of the initialization occurs.
  185.   (The screen is NOT cleared, but white characters on a black background
  186.   are assumed the default for the "standard screen" unless changed.)
  187.  
  188.   You must DEFINE a window before using it.  This means setting its
  189.   size (shape), colors, borders, and some of its operational characteristics
  190.   (e.g., whether it should be cleared every time it is opened).
  191.   You do NOT set its location!  This is done when it is OPENED (displayed).
  192.   It may be opened at any location, provided that it fits ENTIRELY on the
  193.   screen.  The window is assigned a "window number" when it is defined.
  194.   It is a good idea to define all windows at the start of your program,
  195.   since this is when memory is allocated for them.  (If you're going to
  196.   run out of memory, you might as well do it right away.)  
  197.   The program allocates only enough memory for the windows you use.
  198.   Note: The order in which windows are DEFINED is insignificant.
  199.  
  200.   To display a window, you OPEN it, at a particular LOCATION relative to 
  201.   the entire screen (not relative to the currently open window).
  202.   You must have previously DEFINED it.  The area it "covers" (including
  203.   the area changed by the "shadow", if any) is saved, and the window is
  204.   displayed, becoming the "top window" (in a stack).  This also makes it
  205.   the "current window".  All displays, attribute and cursor settings
  206.   affect only the "current window".
  207.   NOTE: You can now make some other (at least partially visible) window
  208.   the "current window", and display to it, but it is a wise policy to
  209.   return to the top window as soon as possible.  This is because the
  210.   ONLY window that can be "closed" is the top window: that is, you must
  211.   "lift off" the windows in the same order in which you "laid them down."
  212.   Your application may require setting up three non-overlapping windows
  213.   on the screen and keeping them open rather permanently.  This is fine,
  214.   but at the end, you must close them in reverse order IF you wish to
  215.   remove them.  If you don't care that they remain on your screen at the
  216.   end of the program, you need not close them.
  217.  
  218.   To display text, there are three typical steps:
  219.     - set the attribute (for subsequently displayed characters)
  220.     - set the cursor (relative to the writeable [non-border] area of the window)
  221.     - display text (including newlines).
  222.   The attribute setting continues until changed.  Even if the window is
  223.   closed and reopened, the last-set attribute will be remembered for EACH
  224.   WINDOW SEPARATELY!
  225.   The cursor will advance one space after displaying any character except
  226.     - \n, which advances it to the start of the following line, scrolling
  227.           the window if necessary
  228.     - \r, which returns it to the start of the current line
  229.     - \t, which tabs to the next multiple-of-8 column within the window,
  230.           advancing to the next line (and even scrolling) if necessary.
  231.   ALL OTHER CHARACTERS are treated as displayable!
  232.  
  233.   When you CLOSE a window, its contents are saved, its current cursor and
  234.   attribute settings are saved, the information it "covered"
  235.   when displayed is redisplayed.
  236.  
  237.  
  238. The CODE
  239.  
  240.   With the source code (available at modest cost), the routines are 
  241.   almost totally portable.  The discussion below explains how hardware-
  242.   dependent items like attribute settings, etc. are tailored to individual
  243.   systems.
  244.  
  245.   The macro LINT, if defined, allows prototypes of the functions
  246.   to be included into your program for type-checking.
  247.  
  248.   The code provided in the standard version will work with 
  249.   Borland's Turbo C and Microsoft C, which both use register return values
  250.   and register variables the same way.
  251.  
  252.   In this package, a structure called a _window may be addressed by its
  253.   "window number", which is assigned to it when it is defined.
  254.  
  255. /*****************************************************************************/
  256. THE WINDOW STRUCTURE
  257. struct _window
  258. {
  259.   /* When defined */
  260.         BITS    wstatus;        /* initially zero if no window defined here. */
  261.         BITS    wbordstyle;
  262.         WATTR   wbordattr;
  263.         RECT    wpane;          /* "writeable" area of window.  May be adjusted
  264.                                    after open by "pane_" functions. */
  265.         RECT    wrectb;         /* possibly bigger than above for borders,
  266.                                    shadow. */
  267.   /* When opened */
  268.         int     wscreen;        /* screen page.  Not necessarily hardware-
  269.                                    related.  Currently force screen 0. */
  270.         SCNCHAR *wunder;        /* pointer to 1st char of block where stuff
  271.                                    covered up is saved. */
  272.   /* When closed */
  273.         WATTR   wdftattr;       /* default attribute in this window (scroll) */
  274.         WATTR   wattr;          /* last set attribute in this window */
  275.         COORD   wrow, wcolumn;  /* 0,0 when w_def()'d, saved cursor value 
  276.                                    when closed. */
  277.         SCNCHAR *wsave;         /* window data, incl border, written to ONLY
  278.                                    when window closed (unless wstatus has
  279.                                    NOSAVE).
  280.                                    IF you later allow writing to memory images
  281.                                    as well as those on screen, or to "hidden"
  282.                                    windows, this may be written to on each
  283.                                    character. */
  284. };
  285.  
  286. /*****************************************************************************/
  287. THE FUNCTIONS
  288.  
  289. ERRCODE w_init(void);
  290.  
  291.         You must invoke this function first.  It figures out what kind of
  292.         video you're using.
  293.         It sets up basic variables, examines hardware by invoking hw_winit(), 
  294.         allocates space, decides which type of output to use, etc.
  295.         The assumption is that windows[] was already defined.
  296.  
  297.         Returns: an error code
  298.                 NO_ERROR        No error.
  299.                 COMPAT_ERR      Not a screen type that BIOS recognizes (2,3,7)
  300.  
  301.  
  302. WNUM    w_def(WNUM w, BITS status, COORD hgt, COORD wid, 
  303.               WATTR attr, BITS bordstyle, WATTR bordattr);
  304.  
  305.         Use this function to define the shape, colors, and characteristics
  306.         of a window you want to use.
  307.         This must be done before the window is opened for the first time,
  308.         and needs to be done only once.
  309.         It allocates buffers for storing window images, sets values.
  310.         Window is not "opened" by this procedure.
  311.         If a border is specified, writable portion of window is smaller than
  312.         the size you specify.
  313.         If no border, entire window can be written to.
  314.         NOTE THAT WE DON'T DEFINE THE STANDARD SCREEN: IT IS ALREADY DEFINED!
  315.         Note also that the screens need not be DEFINED in a stack order,
  316.         but when they are OPENED, the order of opening is stacked, and they
  317.         must be CLOSED in the reverse order.
  318.  
  319.         w       Windows are identified by their WNUM ("window number").
  320.                 Typically, you use a -1 here, instructing the function to
  321.                 assign the window the next available window number, which
  322.                 is returned by the function.  However, if you enter a valid
  323.                 window number (0 < w < MAXWIN), it will be used.
  324.  
  325.         status  bits should be ORed together.  (0 is normal)
  326.                                 set by w_def():
  327.                 CLEAR_ON_OPEN   Clear window every time window is opened.
  328.                 NO_SCROLL       Continue to write in last window position.
  329.                 NOSAVE_ON_CLOSE Not used.
  330.                 DELETE_ON_CLOSE Not used.
  331.                 INVISIBLE       Not used.
  332.                 DONT_CLOSE      Not used.
  333.                 DONT_ERASE.     Not used.
  334.                                 bits set internally:
  335.                 DEFINED_, OPENED_, MAYDELETE_.
  336.  
  337.         hgt and
  338.         wid     dimensions of the window, INCLUDING BORDER, but not including
  339.                 shadow, which is attached left and below if required.
  340.                 top and left are set when opened somewhere.
  341.  
  342.         attr    sets background and foreground standard colors, both the
  343.                 DEFAULT ATTRIBUTE (which remains permanent for clearing and
  344.                                    scrolling the window), and
  345.                 CURRENT ATTRIBUTE (which affects subsequent characters).
  346.                 When you close and reopen windows or switch the current
  347.                 window, the last-set CURRENT ATTRIBUTE is retained and
  348.                 used when you return to that window later.
  349.  
  350.         bordstyle
  351.                 bits which determine which sides have borders, and if so,
  352.                 what kind.  The bits should be ORed together (0=no border).
  353.                 The low-order 8 bits are
  354.                            +---+---+---+---+---+---+---+---+
  355.                            |  top  | bottom|  left | right |
  356.                            +---+---+---+---+---+---+---+---+
  357.                 Note that each "side" of the window requires two bits
  358.                 to describe what sort of border it has:
  359.                         0 = no border, no space allocated for one
  360.                         1 = single line border
  361.                         2 = double line border
  362.                         3 = block border
  363.                 In addition, if you want a shadow, OR in the following:
  364.                         BORD_SHADOW
  365.                 And if you want to set the edge of the screen to the border 
  366.                 color, (the outer edge of display, surrounding the 80*25), 
  367.                 OR in:
  368.                         BORD_EDGE
  369.  
  370.                 Example: Suppose we want single lines on the left and right
  371.                          sides, a double line on the bottom, NO BORDER on
  372.                          the top, and a shadow.  The bordstyle would be:
  373.                             top     bottom   left    right
  374.                            0 * 64 | 2 * 16 | 1 * 4 | 1 * 1 | BORD_SHADOW
  375.                          Bit values:
  376.                              00       10       01      01  | BORD_SHADOW
  377.                          simplified:
  378.                                                       0x25 | BORD_SHADOW
  379.  
  380.                 Both EDGE and SHADOW are IN ADDITION to other borders.
  381.  
  382.         bordattr
  383.                 Sets background and foreground border colors.
  384.                 The border attribute is not changeable later, but you can
  385.                 set the current attribute of the window to something else,
  386.                 then overwrite the border with w_puts().
  387.  
  388.         Returns: EITHER an error code, if there is an error, or
  389.                  the window number that will be used from this point on
  390.                  to reference this window.
  391.                 Does NOT return NO_ERROR, lest there be confusion.
  392.                 All error numbers are assumed to be >= MAXWIN.
  393.                 WNUM_ERR        Attempting to define the a window as number 0,
  394.                                 which is the already-defined "standard window",
  395.                                                   OR
  396.                                 argument w is >= MAXWIN.
  397.                                                   OR
  398.                                 you chose a window number w which is already
  399.                                 in use.
  400.                 MAXWIN_ERR      MAXWIN windows already defined: no room in array.
  401.                 SMALL_ERR       Window is so small there are either no rows
  402.                                 or no columns in it.
  403.                 NOFIT_ERR       Window is too large to fit on screen.
  404.                 BUFFER_ERR      Either the wsave or wunder buffer pointer
  405.                                 is non-NULL.  This should never happen, as it
  406.                                 it initialized to NULL and returned to that
  407.                                 status when a window is w_delete()'d.
  408.                 OM_ERR          Ran out of memory doing a calloc().
  409.  
  410.  
  411. ERRCODE w_open(WNUM w, COORD top, COORD left);
  412.  
  413.         If the CLEAR_ON_OPEN bit was set when the window w was defined,
  414.         then clear the stored display of this window first.
  415.         Open (display) the indicated window at the indicated location,
  416.         and make it the "current window" (the window which will receive
  417.         subsequent w_cursor() settings, w_attr() settings, and displays).
  418.         The last-used attribute of this window becomes the current attribute,
  419.         and the last-used cursor position becomes the current cursor position.
  420.         Color the outer screen edge if BORD_EDGE bit was set when this
  421.         window was defined.  
  422.         Create the shadow if BORD_SHADOW bit was set when this window
  423.         was defined.
  424.  
  425.         w       the window number returned by w_def().
  426.  
  427.         top and 
  428.         left
  429.                 Relative to the standard screen.  If the window has upper/left 
  430.                 border(s), the upper-left corner of the border will be placed 
  431.                 at these coordinates, so the writeable area of the window 
  432.                 may be one row down and/or one column to the right.
  433.  
  434.         Returns: an error code
  435.                 NO_ERROR        No error.
  436.                 WNUM_ERR        Window w is < 0 or >= MAXWIN.
  437.                 WOPND_ERR       Window w is already open.
  438.                 WDEFD_ERR       Window w is not defined.
  439.                 NOFIT_ERR       Window (or its shadow) cannot fit on screen 
  440.                                 in location specified by row, column.
  441.                 any scn_saverect() error
  442.                   NO_ERROR        No error.
  443.                 any scn_loadrect() error
  444.                   NO_ERROR        No error.
  445.                 any w_current() error
  446.                   any w_cursor() error
  447.                     CLIPPED_ERR     row, column cannot be within the current window.
  448.                     any scn_cursor() error
  449.                       NO_ERROR        No error.
  450.                       any hw_cursor() error
  451.                         NO_ERROR        No error.
  452.  
  453.  
  454. ERRCODE w_current(WNUM w);
  455.  
  456.         Make the indicated window the "current window".  You do this when
  457.         you want to write to a window which is NOT the top window.
  458.         This window may have been partially overlaid, so it is the programmer's
  459.         responsibility to insure that reads/writes do not occur on the
  460.         overlaid area.  (A later version may allow writing to overlaid regions.)
  461.         Note that this also prohibits scrolling, if this window is partially
  462.         overlaid.  A "w_open" does a w_current() implicitly.
  463.         This saves the attribute of the previously current window (its
  464.         cursor position is saved continuously), sets the attribute of
  465.         the new current window to be the current attribute, and the cursor
  466.         position in the new current window to be the current cursor position.
  467.  
  468.         Returns: an error code
  469.                 any w_cursor() error
  470.                   CLIPPED_ERR     row, column cannot be within the current window.
  471.                   any scn_cursor() error
  472.                     NO_ERROR        No error.
  473.                     any hw_cursor() error
  474.                       NO_ERROR        No error.
  475.  
  476.  
  477. ERRCODE w_close(WNUM w);
  478.  
  479.         Close the indicated window (i.e., save its contents, remove it
  480.         from the screen, and restore previous overlaid data.  
  481.         Then IF w is the current window, make the next lower window
  482.         the current window.
  483.         w MUST be the top window, but it does NOT have to be the CURRENT WINDOW.
  484.         If w is STDWNUM (the standard screen), it never closes, but does not
  485.         create an error if you attempt to close it.
  486.  
  487.         Returns: an error code
  488.                 NO_ERROR        No error, or w is STDWNUM, which cannot 
  489.                                 be closed.
  490.                 NOTTOP_ERR      w is not top window.
  491.                 any scn_saverect() error
  492.                   NO_ERROR        No error.
  493.                 any scn_loadrect() error
  494.                   NO_ERROR        No error.
  495.                 any w_current() error, which is exactly...
  496.                 any w_cursor() error
  497.                   CLIPPED_ERR     row, column cannot be within the current window.
  498.                   any scn_cursor() error
  499.                     NO_ERROR        No error.
  500.                     any hw_cursor() error
  501.                       NO_ERROR        No error.
  502.  
  503.  
  504. ERRCODE w_delete(WNUM w);
  505.  
  506.         Delete the indicated window, releasing buffer space.  
  507.         It must not be the "standard window" (the full screen).
  508.         It must not be open.
  509.         Avoid this function if possible.  Try to reuse windows rather than
  510.         using a zillion different ones.
  511.  
  512.         Returns: an error code
  513.                 NO_ERROR        No error, or w is STDWNUM, which cannot 
  514.                                 be deleted.
  515.                 WOPND_ERR       Window w is already open.
  516.  
  517.  
  518. ERRCODE w_cursor(COORD row, COORD column);
  519.  
  520.         Set cursor to indicated coordinates (relative to 0,0 at upper-left
  521.         corner of writeable area of current window).
  522.         If either coordinate is the macro POSITION instead of a row or
  523.         column number, the cursor remains in the SAME row or column,
  524.         respectively, and the OTHER coordinate changes.
  525.         NOTE:  This function sets the coordinates logically, but the 
  526.                visible blinking cursor IS NOT SET by the normal invocation
  527.                of this function.
  528.                If you write directly to ram without using ROM routines, 
  529.                the cursor may blink in one place when you are actually 
  530.                writing somewhere else.
  531.                This is no harm, but it misleads the operator.  Occasionally
  532.                in the code we force it into position, but not enough.
  533.                To set the physical cursor yourself, first set the logical
  534.                cursor, then invoke this function as follows:
  535.                   w_cursor( POSITION, POSITION );
  536.                You MAY physically position hardware cursor, but don't
  537.                if you don't have to, as it slows down displays.
  538.  
  539.         TECHNICAL:  Sets screen coordinates to correspond, using scn_cursor().
  540.  
  541.         Returns: an error code
  542.                 CLIPPED_ERR     row, column cannot be within the current window.
  543.                 any scn_cursor() error
  544.                   NO_ERROR        No error.
  545.                   any hw_cursor() error
  546.                     NO_ERROR        No error.
  547.  
  548.  
  549. int     w_putc(int c);
  550.  
  551.         The standard "display a character" command (used by w_puts()).
  552.         Displays character to current location on current window, 
  553.         using most recently set attribute.
  554.         (Attribute may be TRANSPARENT, in which case it will use
  555.         existing attribute at current location.)
  556.  
  557.         The cursor will advance one space after displaying any character except
  558.           - \n, which advances it to the start of the following line, scrolling
  559.                 the window if necessary
  560.           - \r, which returns it to the start of the current line
  561.           - \t, which tabs to the next multiple-of-8 column within the window,
  562.                 advancing to the next line (and even scrolling) if necessary.
  563.         ALL OTHER CHARACTERS are treated as displayable (including control
  564.         characters)!  
  565.         The "current location" advances, scrolling the window if necessary, 
  566.         (unless window was defined with NO_SCROLL bit).
  567.         This works even if you write to last position on screen.
  568.         If cursor WAS within the window, it STAYS within the window.
  569.  
  570.         LATER, not implemented in this version:
  571.         The window may be INVISIBLE, in which case writing
  572.         can be done to saved image without displaying the window.  Otherwise
  573.         writing is always done to the displayed image (screen itself).
  574.  
  575.         Returns: an error code
  576.         Currently, the code returns an error code, not the character.
  577.         In future, might be declared as ERRCODE w_putc(int c);
  578.                 NO_ERROR        No error.
  579.                 any w_cursor() error
  580.                   CLIPPED_ERR     row, column cannot be within the current window.
  581.                   any scn_cursor() error
  582.                     NO_ERROR        No error.
  583.                     any hw_cursor() error
  584.                       NO_ERROR        No error.
  585.  
  586.  
  587. ERRCODE w_puts(char *s);
  588.  
  589.         The standard "display text" command (like "print").
  590.         Displays the NULL-terminated string s in the current attribute
  591.         [or TRANSPARENT] at the current row and column of the current window.
  592.         The text may include \r, \n, \t, which are processed per w_putc().
  593.  
  594.         The "current location" advances character by character, scrolling the 
  595.         window if necessary, (unless window was defined with NO_SCROLL bit).
  596.  
  597.         This is the intelligent output for the general case.
  598.         ERRCODE scn_ws(char *s) may be used for greater speed, but 
  599.         it does not check whether you overwrite window boundaries.
  600.  
  601.         Returns: an error code
  602.                 NO_ERROR        No error.
  603.  
  604.  
  605.               POSSIBLY ENVIRONMENT-DEPENDENT/OPTIMIZABLE FUNCTION
  606.               This function must exist, but may need to be optimized to the
  607.               specific operating system, screen, etc.
  608.  
  609. ERRCODE w_setattr(int attrtype, WATTR attr);
  610.  
  611.         Set a foreground or background color, or 
  612.         set/reset bright or blink attributes of subsequently displayed 
  613.         characters.
  614.  
  615.         The settings may be done incrementally (e.g., "just change the
  616.         background color, but leave the other settings alone", or
  617.         the entire attribute may be set, removing previous settings.
  618.         If screen is memory-mapped, no output takes place when this 
  619.         function is invoked.  (If a terminal, the function hw_setattr()
  620.         is invoked to register the new setting.)  This function ususally
  621.         only affects the appearance of subsequently output characters.
  622.  
  623.         The first argument, attrtype, indicates which kind of setting is
  624.         being done.  The second argument, attr, is the specific value
  625.         to which it should be set.  The values for each are limited to
  626.         those defined in WDEF.H.
  627.  
  628.         attrtype    
  629.                 The first argument Must be one of the following:
  630.                 SET_    to turn ON  BRIGHT, BLINK, or UNDERLINE
  631.                 RESET_  to turn OFF BRIGHT, BLINK, or UNDERLINE
  632.                 FGC_    to set foreground color
  633.                 BGC_    to set background color
  634.                 ENTIRE_ to replace entire attribute (including BLINK, BRIGHT,
  635.                         and UNDERLINE settings)
  636.  
  637.         attr
  638.                 If attrtype is SET_ or RESET_, 
  639.                         this indicates WHICH attribute (among BRIGHT, BLINK, 
  640.                         or UNDERLINE) is being set or reset.
  641.                 If attrtype is FGC_,
  642.                         this should be a macro for beginning with "FG_".
  643.                 If attrtype is BGC_,
  644.                         this should be a macro for beginning with "BG_".
  645.                 If attrtype is ENTIRE_,
  646.                         this should be the ORed value of a foreground color,
  647.                         a background color, and whichever of BRIGHT, BLINK,
  648.                         or UNDERLINE are to be turned ON.  (Of those three,
  649.                         any not named are turned OFF.)
  650.                         If either the foreground or background color is omitted,
  651.                         it defaults to color 0 (black on an IBM PC).
  652.  
  653.         Examples:
  654.                 w_setattr(SET_, BRIGHT);
  655.                 w_setattr(RESET_, BLINK);
  656.                 w_setattr(FGC_, FG_RED);
  657.                 w_setattr(BGC_, BG_CYAN);
  658.                 w_setattr(ENTIRE_, FG_RED|BG_CYAN|BRIGHT);
  659.  
  660.         Note: It would be an error (though it would compile correctly)
  661.         to use
  662.                 w_setattr(BGC_, FG_RED);
  663.         since FG_RED is strictly a foreground color.  The effect would
  664.         be to turn the background to color 0 (black on an IBM PC), and 
  665.         change the foreground to the bit combination of the old and new
  666.         foreground colors.
  667.  
  668.         Returns: an error code
  669.                 NO_ERROR        No error.
  670.  
  671.  
  672. ERRCODE w_scroll(int dir, int num);
  673.  
  674.         Scroll the current window text num lines in direction dir.
  675.         dir     Must be either UP or DOWN.
  676.         num     If 0, means "clear the current window".
  677.  
  678.         This version uses one of the BIOS functions.
  679.  
  680.         Returns: an error code
  681.                 NO_ERROR        No error.
  682.  
  683.  
  684. ERRCODE w_err(ERRCODE);
  685.  
  686.         A function used internally, which you may use also.  It is invoked
  687.         whenever an error code is generated.  It may be used to print a
  688.         message to the operator, or do nothing, or whatever you like.
  689.  
  690.         Returns: the error code given in its argument.
  691.  
  692.  
  693. KEYCHAR getv(void);
  694.  
  695.         The standard "get a character from the keyboard" function.
  696.         Sets the physical cursor, so operator can see where to enter
  697.         a character.  Does not return until a key is pressed.
  698.         It returns a normal ASCII character when that is pressed.
  699.         For function keys, etc., 0xFE00 is ORed into the extended key value.
  700.  
  701.         Returns: The (possibly transformed) key value
  702.  
  703.  
  704. KEYCHAR getcv(void);
  705.  
  706.         This function calls getv(), looks up non-ASCII values in a table,
  707.         then returns the lookup value, if any, otherwise the original value.
  708.         It allows designation of certain keys for HELP or LEFT/RIGHT
  709.         or other purposes in a hardware-independent manner.
  710.         The current version is hardcoded to convert only one value:
  711.           the ESCape key returns the KEYCHAR value "CANCEL".
  712.  
  713.         Returns: The (possibly transformed, then possibly converted) key value
  714.  
  715.  
  716.                            Convenience macros
  717.  
  718. #define w_writerc(row, col, s)  (w_cursor(row, col) ? werrnum : w_puts(s))
  719. #define iswopen(w)              (windows[w].wstatus & WOPENED_)
  720. #define BUG(msg)                printf(msg);
  721. #define w_writexy(col,row,s)    (w_cursor(row, col); w_puts(s))
  722. #define w_gotoxy(x,y)           w_cursor(y,x)
  723. #define w_getcy()               cw->wrow
  724. #define blink()                 w_setattr(SET_, BLINK)
  725. #define noblink()               w_setattr(RESET_, BLINK)
  726. #define bright()                w_setattr(SET_, BRIGHT)
  727. #define nobright()              w_setattr(RESET_, BRIGHT)
  728.  
  729. A SCNCHAR is the chunk of physical data containing the physical character
  730. and attribute.  It is the thing which, in an array, makes up the physical
  731. screen.
  732.  
  733.  
  734.  
  735.  
  736. /*****************************************************************************/
  737.          The following information is probably of little use to you.
  738. /*****************************************************************************/
  739.  
  740.                              Internal functions
  741.  
  742. ERRCODE scn_ws(char *);
  743.                 NO_ERROR        No error.
  744. ERRCODE scn_was(char *);
  745.                 NO_ERROR        No error.
  746. ERRCODE scn_cursor(COORD, COORD);
  747.                 NO_ERROR        No error.
  748.                 any hw_cursor() error
  749. ERRCODE scn_saverect(RECT *, SCNCHAR *);
  750.                 NO_ERROR        No error.
  751. ERRCODE scn_loadrect(RECT *, SCNCHAR *);
  752.                 NO_ERROR        No error.
  753. ERRCODE scn_edge(WATTR attr);
  754.                 NO_ERROR        No error.
  755.  
  756. int     scn_wc(int c);
  757. SCNCHAR scn_wscnchar(SCNCHAR);
  758. SCNCHAR scn_rscnchar(void);
  759. /*
  760. WATTR   scn_ra(void);
  761. int     scn_wconly(int c);
  762. WATTR   scn_waonly(WATTR);
  763. */
  764. SCNCHAR ca_to_scnchar(int, WATTR);
  765. ERRCODE hw_initscn(void);
  766.                 NO_ERROR        No error.
  767.                 COMPAT_ERR      Not a screen type that BIOS recognizes (2,3,7)
  768. ERRCODE hw_cursor(void);
  769.                 NO_ERROR        No error.
  770. #ifdef MEMMAPPED
  771. #define hw_setattr() /* Don't send anything to screen when attribute changes. */
  772. #else
  773. #ifdef LINT
  774. ERRCODE hw_setattr(void);
  775. #endif
  776. #endif
  777.  
  778.                     Functions from the Standard Library
  779.  
  780. char    *calloc(unsigned int, unsigned int);
  781. void    exit(int);
  782. void    free(char *);
  783. int     printf(char *, ...);
  784. int     sprintf(char *, char *,...);    ???
  785. int     strlen(char *);                 ???
  786. int     toupper(int);                   ???
  787.  
  788.         Functions that are MS-DOS- (and possibly compiler-) dependent
  789.  
  790. int             int86(int, struct REGS *, struct REGS *);
  791. unsigned int    peek(unsigned int, unsigned int);
  792.